struct ListNode {
	int val;
	struct ListNode* next;
};

int getDecimalValue(struct ListNode* head_p) {
	unsigned value = 0;
	struct ListNode* node_p = head_p;
	while (1) {
		unsigned bit = node_p->val;
		value = (value << 1) | bit;
		node_p = node_p->next;
		if (node_p == 0) {
			break;
		}
	}
	return value;
}